 
һĿУvbsűҪȡļiniļvbsûֳɶдiniļ֧֣ǿxmlļʹxmldomȡдɸclassʹӦ÷һЩһ¡


Class clsGetProfile 
' `ȥɥ 
Private rootDoc 
' xmlեȥ򥻥åȤ 
' 1ե NOT NULL 
' ꂎʤ 
Public Sub setProfile(strFileName) 
Set data_xml = CreateObject("Microsoft.XMLDOM") 
data_xml.async = False 
data_xml.load(strFileName) 
Set rootDoc = data_xml.documentElement 
End Sub 
' `Όꤹ낎ȡä 
'  1` NOT NULL 
' 2 NOT NULL 
' ꂎ`Όꤹ낎 
Public Function getItem(strSectionName, itemName) 
Set sectionNode = rootDoc.selectSingleNode(strSectionName) 
getItem = sectionNode.selectSingleNode(itemName).attributes(0).nodeValue 
End Function 
End Class 
' ʹåץ 
' 饹󥹥󥹤ɤ 
'Dim config : Set config = New clsGetProfile 
' åեȥ򥻥åȤ 
'Call config.setProfile("Config.xml") 
' `Όꤹ낎򥲥åȤ 
'WScript.Echo config.getItem("MessageDefine", "INFO.001") 
'WScript.Echo config.getItem("MessageDefine", "INFO.003") 
'WScript.Echo config.getItem("MessageDefine", "ERROR.009") 
'WScript.Echo config.getItem("MessageDefine", "ERROR.012") 
Class clsGetProfile 
' `ȥɥ 
Private rootDoc 
' xmlեȥ򥻥åȤ 
' 1ե NOT NULL 
' ꂎʤ 
Public Sub setProfile(strFileName) 
Set data_xml = CreateObject("Microsoft.XMLDOM") 
data_xml.async = False 
data_xml.load(strFileName) 
Set rootDoc = data_xml.documentElement 
End Sub 
' `Όꤹ낎ȡä 
'  1` NOT NULL 
' 2 NOT NULL 
' ꂎ`Όꤹ낎 
Public Function getItem(strSectionName, itemName) 
Set sectionNode = rootDoc.selectSingleNode(strSectionName) 
getItem = sectionNode.selectSingleNode(itemName).attributes(0).nodeValue 
End Function 
End Class 
' ʹåץ 
' 饹󥹥󥹤ɤ 
'Dim config : Set config = New clsGetProfile 
' åեȥ򥻥åȤ 
'Call config.setProfile("Config.xml") 
' `Όꤹ낎򥲥åȤ 
'WScript.Echo config.getItem("MessageDefine", "INFO.001") 
'WScript.Echo config.getItem("MessageDefine", "INFO.003") 
'WScript.Echo config.getItem("MessageDefine", "ERROR.009") 
'WScript.Echo config.getItem("MessageDefine", "ERROR.012") 


ļʽ 



<?xml version="1.0" encoding="UTF-8"?> 
<Configuration> 
<!--å`x 
--> 
<MessageDefine> 
<Info.001 value="I_ʼ"/> 
<Info.002 value="IKˡ"/> 
<Info.003 value="IKˡ"/> 
<Info.004 value="Iֹ"/> 
</MessageDefine> 
<!--  
--> 
<OtherSection> 
<host value="192.168.0.241"/> 
<user value="root"/> 
</OtherSection> 
<WindowsLogToolConfig> 
<host value="192.168.0.188"/> 
<port value="3306"/> 
</WindowsLogToolConfig> 
</Configuration> 

